﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Cut : MonoBehaviour
{

    private int Ropenum;

    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            CuttheRope();

        }
    }

    private void CuttheRope()
    {
        RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

        if (hit.collider != null)
        {
            if (hit.collider.tag == "Rope")
            {
                if (hit.collider.gameObject.GetComponentInParent<CreatRope>().isCut == false)
                {
                    Ropenum = hit.collider.gameObject.GetComponent<Ropenum>().num;
                    hit.collider.gameObject.GetComponentInParent<CreatRope>().isCut = true;
                    hit.collider.gameObject.GetComponentInParent<CreatRope>().Ropenum = Ropenum;

                    hit.collider.gameObject.SetActive(false);
                }
            }

        }

    }

}
